import { ParamsConst } from "../../../common/global/ParamsConst";
import { ClockManager } from "../../manager/ClockManager";
import { CacheManager } from "../../../../com/gengine/manager/CacheManager";
//class PulseSharedObject
    
    export  class PulseSharedObject
    {
        

        public static save(arg1: string, arg2: Boolean): void
        {
            if (PulseSharedObject._isCache == false) 
            {
                return;
            }
            var loc1=ParamsConst.instance.username;
            var loc2=ClockManager.instance.nowDate;
            if (arg2 == false) 
            {
                loc2 = null;
            }
            PulseSharedObject.getSharedObject();
            PulseSharedObject._userDataObj[loc1 + "_" + arg1] = loc2;
            PulseSharedObject._sharedObject.data.userDataObj = PulseSharedObject._userDataObj;
            return;
        }

        public static isTodayNotTips(arg1: string): Boolean
        {
            var loc3=null;
            if (PulseSharedObject._isCache == false) 
            {
                return false;
            }
            var loc1=ParamsConst.instance.username;
            var loc2=ClockManager.instance.nowDate;
            PulseSharedObject.getSharedObject();
            if (PulseSharedObject._userDataObj[loc1 + "_" + arg1]) 
            {
                if (!((loc3 = PulseSharedObject._userDataObj[loc1 + "_" + arg1] as Date) == null) && loc3.date == loc2.date && loc3.month == loc2.month && loc3.fullYear == loc2.fullYear) 
                {
                    return true;
                }
            }
            return false;
        }

        public static saveValue(arg1: string, arg2: Object): void
        {
            if (PulseSharedObject._isCache == false) 
            {
                return;
            }
            var loc1=ParamsConst.instance.username;
            PulseSharedObject.getSharedObject();
            PulseSharedObject._userDataObj[loc1 + "_" + arg1] = arg2;
            PulseSharedObject._sharedObject.data.userDataObj = PulseSharedObject._userDataObj;
            return;
        }

        public static getValue(arg1: string): Object
        {
            var loc1=ParamsConst.instance.username;
            PulseSharedObject.getSharedObject();
            return PulseSharedObject._userDataObj[loc1 + "_" + arg1];
        }

        /* internal  */static getSharedObject(): void
        {
            if (PulseSharedObject._sharedObject == null) 
            {
                PulseSharedObject._sharedObject = CacheManager.instance.getLocal(PulseSharedObject.Pulse_NotTip);
                PulseSharedObject._sharedObject.addEventListener(flash.events.NetStatusEvent.NET_STATUS, PulseSharedObject.onNetStatusEvent);
            }
            if (PulseSharedObject._userDataObj == null) 
            {
                PulseSharedObject._userDataObj = PulseSharedObject._sharedObject.data.userDataObj;
                if (PulseSharedObject._userDataObj == null) 
                {
                    PulseSharedObject._userDataObj = {};
                }
            }
            return;
        }

        /* internal  */static onNetStatusEvent(arg1: Object /* flash.events.NetStatusEvent */): void
        {
            if (arg1.info.code != "SharedObject.Flush.Failed") 
            {
                PulseSharedObject._isCache = true;
            }
            else 
            {
                PulseSharedObject._isCache = false;
            }
            return;
        }

        /* internal */ static /* const */Pulse_NotTip: string="pulse/Pulse_NotTip";

        /* internal */ static /* var */_userDataObj: Object;

        /* internal */ static /* var */_sharedObject: Object /* flash.net.SharedObject */;

        /* internal */ static /* var */_isCache: Boolean=true;
    }

            PulseSharedObject._isCache = true;
        